﻿using System;
using System.Collections.ObjectModel;
using System.Collections.Generic;

using Finance.Entites;
using Finance.Service.Interfaces;

namespace Finance.Service.Implements
{
    /// <summary>
    /// Store the data with json format in the disk
    /// </summary>
    /// <typeparam name="TEntity">The graph of store object contains in ObserableCollection</typeparam>
    public class MockAccountDataStore : JsonDataStore<Account>
    {
        private static ObservableCollection<Account> _AccountCollections = new ObservableCollection<Account>();

        public override ObservableCollection<Account> Items
        {
            get
            {
                if (base._Items == null || base._Items.Count == 0)
                {
                    _AccountCollections.Clear();

                    var R = new Random();
                    var accounts = new List<Account>(){
                        new Account() { Name = "口袋现金",Group="现金账户"},
                        new Account() { Name = "库存现金",Group="现金账户"},

                        new Account() { Name = "工商银行",Group="银行账号"},
                        new Account() { Name = "农业银行",Group="银行账号"},
                        new Account() { Name = "建设银行",Group="银行账号"},
                        new Account() { Name = "招商银行",Group="银行账号"},

                        new Account() { Name = "股票账户",Group="金融账户"},
                        new Account() { Name = "基金账户",Group="金融账户"},

                        new Account() { Name = "支付宝",Group="虚拟账户"},
                        new Account() { Name = "财付通",Group="虚拟账户"},
                        new Account() { Name = "公交卡",Group="虚拟账户"},
                        new Account() { Name = "一卡通",Group="虚拟账户"},
                        new Account() { Name = "其他账户",Group="其他账户"},
                    };

                    foreach (var account in accounts)
                    {
                        _AccountCollections.Add(account);
                    }
                    base._Items = _AccountCollections;
                    base.Commit();
                }
                return base._Items;
            }
        }
    }
}
